/*send.c*/
#include <stdio.h>   
#include <sys/types.h>   
#include <sys/ipc.h>   
#include <sys/msg.h>   
#include <errno.h>   
#include <stdlib.h>
#include<string.h>
#include<unistd.h>
#include<string>

#define MSG_SEND 1025
#define MSG_RECV 1024 
using namespace std;
struct msgstru
{
	long msgtype;
	char msgtext[100];
	int port;
	int expire;

};

int main()
{
	int msg_type;
	int ret_value;
	int send_msqid, recv_msqid;
	send_msqid = msgget(MSG_SEND, IPC_CREAT);
	recv_msqid = msgget(MSG_RECV, IPC_CREAT);
	printf("%d  %d\n", send_msqid, recv_msqid);
	msgstru A{ 1,"616f50032dfb4491be3dd1f12f83a9d5;192.168.1.1",20,100};
	msgstru b;
	printf("[%d]send:%s\n", getpid(), A.msgtext);
	ret_value = msgsnd(send_msqid, &A, sizeof(struct msgstru), 0);
	ret_value = msgrcv(recv_msqid, &A, sizeof(struct msgstru), 0, 0);
	printf("[%d]recv:%s %d %d\n", getpid(), A.msgtext,A.port,A.expire);
	return 0;
}